package com.kittenhuffing;

import java.util.Vector;

import org.jbox2d.collision.shapes.PolygonShape;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.*;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.ShapeFill;
import org.newdawn.slick.geom.Polygon;
import org.newdawn.slick.geom.Shape;

public class Environment {
	Body staticBody;
	Vector<Fixture> land;
	Polygon visual;
	
	public Environment(GameplayState state) {
		land = new Vector<Fixture>();
		
		//This creates a 
		BodyDef groundBodyDef = new BodyDef();
		groundBodyDef.position.set(0, 0);
		staticBody = state.getPhysics().createBody(groundBodyDef);
		Vec2[] vec2_points = new Vec2[3];
		float[] points = { 500, 500, 1000, 500, 750, 300 };
		vec2_points[0] = new Vec2(points[0] / KittenHuffing.SCALE, points[1] / KittenHuffing.SCALE);
		vec2_points[1] = new Vec2(points[2] / KittenHuffing.SCALE, points[3] / KittenHuffing.SCALE);
		vec2_points[2] = new Vec2(points[4] / KittenHuffing.SCALE, points[5] / KittenHuffing.SCALE);
		PolygonShape shape = new PolygonShape();
		shape.set(vec2_points, 3);
		land.add(staticBody.createFixture(shape, 0));
		visual = new Polygon(points);
	}
	
	public void subtract(Shape s) {
		//TODO Subject Shape s from the land, used for explosions
	}
	
	public void render(GameContainer gc) {
	      gc.getGraphics().draw(visual);
	}
}
